package day04;

import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.Cookie;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import util.CookieUtil;

import java.io.IOException;
import java.net.URLDecoder;

@WebServlet("/getCookie")
public class GetCookieServlet extends HttpServlet {

    @Override
    protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        System.out.println("GetCookieServlet.service()");

//        Cookie[] cookies=request.getCookies();
//
//
//        for (Cookie cookie : cookies) {
//            System.out.println(cookie.getName()+"="+ URLDecoder.decode(cookie.getValue(),"utf-8"));
//        }


        System.out.println(CookieUtil.findCookie("username",request));

    }
}
